<?php
/**
 * User:chendenan
 * Created On 2022/3/19 0019 21:36
 */
namespace app\common\model\mysql;
class GoodsSku extends ModelBase {
    public function goods(){
        return $this->hasOne(Goods::class,"id","goods_id");
    }
    public function getByGoodsId($goodsId = 0){
        $where = [
            "goods_id" => $goodsId,
            "status" => config("status.mysql.table_normal"),
        ];
        return $this->where($where)->select();
    }
    public function decStock($id,$num) {
        return $this->where("id","=",$id)
            ->dec("stock",$num)
            ->update();
    }
}